package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.constant.MessageConstant;
import com.itheima.dao.MobileSetmealDao;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.MobileSetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = MobileSetmealService.class)
@Transactional
public class MobileSetmealServiceImpl implements MobileSetmealService {
    @Autowired
    private MobileSetmealDao mobileSetmealDao;
    @Override
    public Result getSetmeal() {
        try {
            List<Setmeal> setmeal = mobileSetmealDao.getSetmeal();
            return new Result(true,"查询成功",setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
    }
/*
* 动态查询详情页面
* */
    @Override
    public Result findById(int id) {
        try {
            Setmeal setmeal = mobileSetmealDao.findById(id);
            return new Result(true,"查询详情成功",setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"查询详情失败");
        }
    }
}
